'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { agentjoinService } from '../service/agentjoin';

/** 合伙人申请api对象 */
@prefix('agentjoin')
class AgentjoinController {
    /**
     * 
     * @api {post} /agentjoin/query  查询合伙人申请记录
     * @apiDescription 查询合伙人申请记录
     * @apiName query
     * @apiParam (参数) {String} offset   页码
     * @apiParam (参数) {String} limit    每页显示条数
     * @apiSampleRequest /agentjoin/query
     * @apiGroup agentjoin
     * @apiVersion 1.0.0
     */
    @router('/query', { method: 'post' })
    async query(ctx: Koa.Context) {
        let result = await agentjoinService.query(ctx.request.body);
        response(ctx, result);
    }
    /**
     * 
     * @api {post} /agentjoin/save  保存合伙人申请信息
     * @apiDescription 保存合伙人申请信息
     * @apiName save
     * @apiParam (参数) {String} token   用户token
     * @apiParam (参数) {String} name    联系人
     * @apiParam (参数) {String} phone   联系电话
     * @apiParam (参数) {String} area    所在区域
     * @apiParam (参数) {String} remarks    备注
     * @apiSampleRequest /agentjoin/save
     * @apiGroup agentjoin
     * @apiVersion 3.0.0
     */
    @router('/save', { method: 'post' })
    async save(ctx: Koa.Context) {
        let result = await agentjoinService.save(ctx.request.body);
        response(ctx, result);
    }



    @router('/update',{method:'post'})
    async updatejoin(ctx: Koa.Context) {
        let result = await agentjoinService.updatestatus(ctx.request.body);
        response(ctx, result);
    }

    /**
     * 
     * @api {post} /agentjoin/queryByCode  查询合伙人申请信息（小程序）
     * @apiDescription 查询合伙人申请信息（小程序）
     * @apiName queryByCode
     * @apiParam (参数) {String} token  用户token
     * @apiSampleRequest /agentjoin/queryByCode
     * @apiGroup agentjoin
     * @apiVersion 1.0.0
     */
    @router('/queryByCode', { method: 'post' })
    async queryByCode(ctx: Koa.Context) {
        let result = await agentjoinService.queryByCode(ctx.request.body.token);
        response(ctx, result);
    }
    @router('/querybyid', { method: 'post' })
    async querybyid(ctx: Koa.Context) {
        let result = await agentjoinService.querybyid(ctx.request.body);
        response(ctx, result);
    }
}